<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class CreateCategoriesTable extends Migration
{
    private $table = 'categories';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('title', 255)->comment('目录名称');
            $table->text('description')->comment('目录介绍');
            $table->tinyInteger('type')->default(1)->comment('目录类型，1.商品');
            $table->unsignedInteger('sort')->default(0)->comment('显示权重,值越大越靠前');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `{$this->table}` COMMENT '目录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->table);
    }
}
